#include <iostream>

using namespace std;

const int N = 5e5 + 10;

typedef long long LL;

LL f1[N], f2[N];

int k;
string s;
char s1, s2;

int main()
{
  cin >> k >> s >> s1 >> s2;
  int n = s.size();
  s = " " + s;
  for(int i = 1; i <= n; i++)
  {
    f1[i] = f1[i - 1]; 
    f2[i] = f2[i - 1];
    if(s[i] == s1) f1[i]++;
    if(s[i] == s2) f2[i]++;
  }
  for(int i = 1; i <= n; i++) cout << f2[i] << " ";
  cout << endl;
  LL cnt = 0; 
  for(int i = 1; i + k - 1 <= n; i++)
  {
    if(s[i] == s1)
    {
      cnt += f2[n] - f2[i + k - 1 - 1];
    }
  }
  cout << cnt << endl;
  return 0;
}
